﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace TicTacToe.Core
{
    static class Extensions
    {
        public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> items)
        {
            foreach (var item in items)
                collection.Add(item);
        }

        public static byte ToByte(this string str)
        {
            return byte.Parse(str);
        }

        public static int ToInt(this string str)
        {
            return int.Parse(str);
        }

        public static T Random<T>(this IEnumerable<T> e)
        {
            var r = new Random();
            var array = e.ToArray();
            return array[r.Next(0, array.Length)];
        }
    }
}
